/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.hiof.moraa.server.controller.restfulservice;

import com.hiof.moraa.server.service.AthleteHealthFeedService;
import com.hiof.moraa.server.service.LiveLocationService;
import com.hiof.moraa.server.service.model.Feed;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * @author Bergy
 */
@Controller
@RequestMapping("/restfulservice/healthFeed")
public class HealthFeedController {

    @Autowired
    AthleteHealthFeedService athleteHealthFeedService;

    @RequestMapping(value = "/athlete", method = RequestMethod.POST)
    @ResponseBody
    public Feed receiveAthleteHealthFeed(
            @RequestParam("athleteId") int athleteId,
            @RequestParam("bloodPressure") double bloodPressure,
            @RequestParam("heartRate") double heartRate,
            @RequestParam("status") String status) throws Exception {
        return athleteHealthFeedService.insertHealthFeed(athleteId, bloodPressure, heartRate, status);
    }


    @RequestMapping(value = "/athlete/history", method = RequestMethod.POST)
    @ResponseBody
    public List<Feed> getHeathFeedHistory(
            @RequestParam("athleteId") int athleteId) throws Exception {
        List<Feed> result = new ArrayList<Feed>();
        result.addAll( athleteHealthFeedService.getHeartRateHistory(athleteId));
        return result;
    }
}
